//
//  GrafftiCell.m
//  CROSBY
//
//  Created by Harvey on 2018/4/4.
//  Copyright © 2018年 Haley. All rights reserved.
//

#import "GrafftiCell.h"

@implementation GrafftiCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initSubView];
    }
    return self;
}

- (void)initSubView
{
    self.customView = [[LSCustomView alloc] initWithFrame:CGRectZero];
    [self.contentView addSubview:self.customView];
}

- (void)setData:(NSArray *)data
{
    _data = data;
    self.customView.data = data;
    
    CGFloat graH = kWidth/kGraffiCols * kGraffiRows;
    self.customView.frame = CGRectMake(0, 5, kWidth, graH);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
    if (selected) {
        self.contentView.layer.borderColor = RGBColor(26, 178, 10, 1).CGColor;
        self.contentView.layer.borderWidth = 1;
    } else {
        self.contentView.layer.borderColor = [UIColor clearColor].CGColor;
        self.contentView.layer.borderWidth = 0;
    }
}

#pragma mark - Public method
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"GrafftiCell";
    GrafftiCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[GrafftiCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor clearColor];
        cell.contentView.backgroundColor = [UIColor clearColor];
    }
    return cell;
}

@end
